package mypazar.pazar;

import jason.environment.grid.GridWorldView;

import java.awt.Color;
import java.awt.Font;
import java.awt.Graphics;

public class PazarView extends GridWorldView {

	private static final int PERSON_AGENT_MAX_INDEX = PazarMain.PERSON_AGENT_COUNT - 1;

	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;

	public PazarView(PazarModel model) {
		super(model, "My Pazar", 600);
		defaultFont = new Font("Arial", Font.BOLD, 18); // default font
		setVisible(true);
		repaint();
	}

	/** draw application objects */
	@Override
	public void draw(Graphics g, int x, int y, int object) {
		switch (object) {
		case PazarModel.STALL:
			drawStall(g, x, y);
			break;
		}
	}

	@Override
	public void drawAgent(Graphics g, int x, int y, Color c, int id) {
		String label = "AG" + (id + 1);
		c = Color.blue;
		if (id > PERSON_AGENT_MAX_INDEX) {
			label = "SMAN" + (id - PERSON_AGENT_MAX_INDEX);
			c = Color.yellow;
		}
		super.drawAgent(g, x, y, c, -1);
		if (id > PERSON_AGENT_MAX_INDEX) {
			g.setColor(Color.black);
		} else {
			g.setColor(Color.white);
		}
		super.drawString(g, x, y, defaultFont, label);
	}

	public void drawStall(Graphics g, int x, int y) {
		super.drawObstacle(g, x, y);
		g.setColor(Color.white);
		drawString(g, x, y, defaultFont, "STALL");
	}
}